'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {

    //注册
    async sign() {
        const { ctx, app } = this;
        const { username, password, phone } = ctx.request.body;
        const data = await app.mysql.get("user", { username });

        if (data) {
            ctx.body = {
                code: 0,
                msg: "账号已被注册",
            };
        } else {
            await app.mysql.insert("user", {
                username,
                password,
            });

            ctx.body = {
                code: 1,
                msg: "注册成功",
            };
        }
    }








}

module.exports = HomeController;